import spacy

from spacy import displacy
nlp=spacy.load('en_core_web_sm')
def helper(s,p):
    s_split=s.split()
    p_split=p.split()
    ans=[]
    i=0
    while i<len(s_split):
        tmp_i=i
        j=0
        while tmp_i < len(s_split) and j <len(p_split) and s_split[tmp_i]==p_split[j]:
            tmp_i+=1
            j+=1
        if j==len(p_split):
            #for p in p_split:
            ans.append("B")
            b=aa.count(" ")
            while b:
                ans.append("I")
                b-=1

            i=tmp_i
        else:
            ans.append("O")
            i+=1
    return  ans
doc=nlp('my son-a good job hha. see: good (job). at dog day')
list=[]
list2=[]
aa='son-a good'
for token in doc.sents:
    print(token)
    if aa in str(token):
        list2.extend(helper(str(token),aa))
        list.extend(list2+["O"] )
        list2.clear()
    else:
        for res in token:
            list.append("O")
print(doc)
# print(len(doc))

print(len(list))

print(" ".join(list))

